package com.drojian.demo1.test1;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.drojian.demo.R;

public class RadioGroupActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {
    private TextView textView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio_group);
        Button back = findViewById(R.id.back);

        RadioGroup radioGroup = findViewById(R.id.radioGroup1);
        textView= findViewById(R.id.radio_textView_group1);
        radioGroup.setOnCheckedChangeListener(this);

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    public void onCheckedChanged(RadioGroup group, int checkedId) {
        if(checkedId== R.id.nan){
            textView.setText("你是个帅气的男孩");
        }else{
            textView.setText("你是一个漂亮的女孩");
        }
    }
}